home *** CD-ROM | disk | FTP | other *** search
- /* merge2.c - generalized external sort */
- #include "stdio.h"
- #include "cminor.h"
- #include "merge1.h"
- #include "sortspec.h"
-
-
- int (*compfun) () ; /* store address of compare fun. here */
- extern SORTSPEC sspec ; /* sortspec. filled out by getspec */
-
- char scra[68] = "scra" ; /* prefixes for scratch file names */
- char scrb[68] = "scrb" ;
-
- main(argc,argv)
- int argc ; /* number of words in command line */
- char *argv[] ; /* pointers to each word */
- {
- /* check to see that file names were specified */
- if( argc < 3 )
- { printf(" need file names \n") ;
- printf(" USAGE: merge1 input-file output-file \n") ;
- exit(1) ;
- }
- getspec(argc,argv) ; /* get sort spec. from the command line */
- compfun = sspec.pcomp ; /* set up compare fun. address */
- dosort(argv[1],argv[2]) ; /* do the sort */
- }
-
-
- int dosort(fromfile,tofile)
- char fromfile[] ; /* input for sort */
- char tofile[] ; /* put the output here */
- {
- int nruns ;
- /* form runs from input file */
- nruns = formruns(fromfile,scra,tofile) ;
- /* now merge runs */
- domerge(scra,scrb,tofile,nruns) ;
- }
-
-